package home.app.t1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class HelloWorld extends Activity
{
    private Button babout;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

//        babout = (Button) findViewById(R.id.button);
//        babout.setOnClickListener(new View.OnClickListener() {
//            public void onClick(View view) {
//                   launchAbout(null);
//            }
//        });


    }

    public void launchAbout(View view)
    {

        Intent i = new Intent(this,about.class);
        i.putExtra("usuario","israel");
        i.putExtra("serial","ASD123");

        //startActivity(i);
        startActivityForResult(i,1234);

    }

    @Override protected void onActivityResult (int requestCode, int resultCode, Intent data)
    {
        if (requestCode==1234 && resultCode==RESULT_OK) {
            String res = data.getExtras().getString("resultado");
        }
    }


    public void salir(View view) {

        finish();

    }

    @Override public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true; /** true -> el men� ya est� visible */
    }

    @Override public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.about:
                launchAbout(null);
                break;
            case R.id.config:
                startActivity(new Intent(this, preferences.class));
                break;

            case R.id.salir:
                salir(null);
                break;
        }
        return true; /** true -> consumimos el item, no se propaga*/
    }


    public void launchIntent(View view)
    {

        android.content.Intent i = new android.content.Intent(this,Intento.class);

        startActivity(i);


    }


}
